Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding ability to set OSD of type DateAndTime.
The function setOSD from lib/media.js previously only supported the addition of Plain Text, as indicated in the comment at line 1286: "ONVIF can handle custom positions, date/time, text, font sizes, transparency, images, etc. We only support Plain Text."
As part of my work, I encountered the need to configure the OSD of date and time for certain cameras. Upon reviewing the Onvif MediaBinding specifications available at https://www.onvif.org/ver10/media/wsdl/media.wsdl and https://www.onvif.org/ver20/media/wsdl/media.wsdl (both media and media2 versions), I found that in the setOSD function, it is possible to set the Type as DateAndTime for configuring date and time display.
Furthermore, I examined the output of the getOSDs function for my cameras and observed that for the OSD date-time, the property "textString" was of type 'DateAndTime'.
For instance, here is the result of getOSDs for one of my cameras:
[ { '$': { token: 'OSD_DATE_TIME' }, videoSourceConfigurationToken: 'VideoSource_token_1', type: 'Text', position: { type: 'Custom', pos: { y: 0.980000019, x: 0.319999993 } }, textString: { type: 'DateAndTime', dateFormat: 'yyyy/MM/dd', timeFormat: 'HH:mm:ss', fontSize: 16, fontColor: [Object], extension: [Object] } },
For adding the ability to change OSD date and time, I firstly I changed the part of TextString in the method setOSD line 1311 as follows -
To -
Added hard-coded the date and time format.
I checked it with my cameras and it works properly, I succeeded to set date and time OSD.
For supported both Plain and DateAndTime, I added an input to the function - dateFormat and timeFormat as I described here -
and changed the TextString part to be -